﻿#ifndef MESSAGEUTIL_H
#define MESSAGEUTIL_H

/*
 * 该工具类用于生成ControlMessage和DataMessage
 * 这些消息的生成规律我参考的是HSMS标准中的那张表格
 * 总的方向是：Message-->QByteArray
 */
#include "src/enum/secsenum.h"
#include "src/util/conversionutil.h"
#include "src/messagetext/text.h"

#include <QObject>

class MessageUtil : public QObject
{
    Q_OBJECT
public:
    /*
     * 针对ControlMessage,它的Text内容为空,我只需要组装好Header的内容即可
     */
    static QByteArray Select_Req(quint16 sessionId,
                                 quint32 transactionId);

    static QByteArray Select_Rsp(quint16 sessionId,
                                 quint32 transactionId,
                                 SecsEnum::SelectStatus select_status);

    static QByteArray DeSelect_Req(quint16 sessionId,
                                   quint32 transactionId);

    static QByteArray DeSelect_Rsp(quint16 sessionId,
                                   quint32 transactionId,
                                   SecsEnum::DeselectStatus deselect_status);

    static QByteArray Link_Test_Req(quint32 transactionId);

    static QByteArray Link_Test_Rsp(quint32 transactionId);

    static QByteArray Reject_Req(quint16 sessionId,
                                 quint32 transactionId,
                                 SecsEnum::RejectReasonCode reason_code,
                                 quint8 reject_message);

    static QByteArray Separate_Req(quint16 sessionId,
                                   quint32 transactionId);


    /*
     * 针对DataMessage,除了Header的内容之外,我还需要在构造它时指定它的Text信息,stream和function信息,当前消息是否需要回复
     */
    static QByteArray SxFy(quint16 sessionId,
                           quint32 transactionId,
                           int stream,
                           int function,
                           bool withReply,
                           Text* messageText);
};

#endif // MESSAGEUTIL_H
